package com.tegistuff.webos.run.debugger.commands;

import com.tegistuff.webos.run.debugger.breakpoints.WebOSBreakpointWrapper;
import org.json.JSONException;

/**
 * WebOSChangeBreakpointCommand.java
 *
 * Copyright (C) 2011-2012 Timo Tegtmeier.
 * All rights reserved.
 */
public class WebOSChangeBreakpointCommand extends WebOSDebuggerCommand {

    private WebOSBreakpointWrapper myBreakpoint;
    private boolean myState;

    public WebOSChangeBreakpointCommand(WebOSBreakpointWrapper wrapper, boolean state) {
        myBreakpoint = wrapper;
        myState = state;
    }

    @Override
    public void execute() throws JSONException {
        runRequest(ourAppDebugSession.getChangeBreakpointRequest(myBreakpoint.getBreakpointNumber(), myState));
    }

    @Override
    protected void onSuccess() throws JSONException {
        myBreakpoint.setEnabled(myState);
    }

}
